#pragma once

#include "RBTree.h"
namespace MyMap {
	template <class K, class V>
	class Map {
		struct Get {
			const K& operator() (const pair<K, V>& data) {
				return data.first;
			}
		};
	public:
		typedef typename RBTree<K, pair<const K, V>, Get>::iterator iterator;
		typedef typename RBTree<K, pair<const K, V>, Get>::con_iterator con_iterator;

		pair<iterator,bool> Insert(const pair<K, V>& data) {
			return _mt.Insert(data);
		}
		iterator begin() {
			return _mt.begin();
		}
		iterator end() {
			return _mt.end();
		}
		con_iterator begin() const {
			return _mt.begin();
		}
		con_iterator end() const {
			return _mt.end();
		}
		V& operator[](const K& data) {
			pair<iterator,bool> ret = Insert(make_pair(data,V()));
			return ret.first->second; 
		}
	private:
		RBTree<K, pair<const K, V>, Get> _mt;
	};
}